const router = require('koa-router')();

const script = require('./scripts/capitaland');

router.prefix('/api/iworkflow/log');

router.get('/:env/thirdparty/:bizFormId', async (ctx, next) => {
  let env = ctx.params.env;
  let bizFormId = ctx.params.bizFormId;

  let rs = await ctx.getDbHelper(`iWorkflow(${env})`).queryForList(script.GetThirdPartyLogs, { bizFormId }, null, 'CapitaWorkflowCenter');

  ctx.body = rs;
});

router.post('/:env/redoCall/:logId', async (ctx, next) => {
  let env = ctx.params.env;
  let logId = ctx.params.logId;

  let rs = await ctx.getDbHelper(`iWorkflow(${env})`).queryForList(script.RedoThirdPartyLog, { id: logId }, null, 'CapitaWorkflowCenter');

  ctx.body = rs;
});

module.exports = router;